package org.aplikator.server.persistence;

import org.aplikator.client.shared.data.Record;
import org.aplikator.server.Context;

public interface PersisterTriggers {

    void onPrepare(Record record, boolean isCopy, Context ctx);

    void onCreate(Record record, Context ctx);

    void onUpdate(Record record, Context ctx);

    void onDelete(Record record, Context ctx);

    void onLoad(Record record, Context ctx);
    
    void afterCommit(Record record, Context ctx);

    public static class Default implements PersisterTriggers{

        @Override
        public void onPrepare(Record record, boolean isCopy, Context ctx) {
        }

        @Override
        public void onCreate(Record record, Context ctx) {
        }

        @Override
        public void onUpdate(Record record, Context ctx) {
        }

        @Override
        public void onDelete(Record record, Context ctx) {
        }

        @Override
        public void onLoad(Record record, Context ctx) {
            record.setPreviewProperty(record.toHTML());
        }
        
        @Override
        public void afterCommit(Record record, Context ctx) {
        }
    }

}
